<?php
$gal = (int)$_GET['gal'];
$pic = (int)$_GET['pic'];
$number = queryScalar('SELECT number FROM gallery_picture WHERE gallery_id=:gal AND picture_id=:pic',
	array('gal'=>$gal,'pic'=>$pic));
$count = queryScalar('SELECT COUNT(*) FROM gallery_picture WHERE gallery_id=:gal AND number<:number',
	array('gal'=>$gal,'number'=>$number));
header('Location: '.$prefix.'/kep?gal='.$gal.'&block='.$count);
die();
?>